"""
pack、grid、place布局方式比较

pack：简单快速布局
grid：表格型复杂布局
place：像素级精确控制
"""


import tkinter as tk

root = tk.Tk()
root.title("三种布局方式比较")   
root.geometry("400x400+1000+100")

# pack 布局
frame_pack = tk.Frame(root, bd=2, relief="groove")
tk.Label(frame_pack, text="Pack布局").pack()
tk.Button(frame_pack, text="按钮1").pack(side="left")
tk.Button(frame_pack, text="按钮2").pack(side="left")
frame_pack.pack(pady=10)

# grid 布局
frame_grid = tk.Frame(root, bd=2, relief="groove")
tk.Label(frame_grid, text="Grid布局").grid(row=0, columnspan=2)
tk.Button(frame_grid, text="A1").grid(row=1, column=0)
tk.Button(frame_grid, text="A2").grid(row=1, column=1)
frame_grid.pack(pady=10)

# place 布局
frame_place = tk.Frame(root, bd=2, relief="groove", width=200, height=100)
tk.Label(frame_place, text="Place布局").place(x=50, y=10)
tk.Button(frame_place, text="按钮1").place(x=10, y=40)
tk.Button(frame_place, text="按钮2").place(x=80, y=40)
frame_place.pack(pady=10)


root.mainloop()